﻿<UserControl 
    xmlns:toolkit="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit"  
    x:Class="TM.QWeibo.Client.UserControls.MessageList"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Foreground="{StaticResource PhoneForegroundBrush}"
    d:DesignHeight="480" d:DesignWidth="480">
    <UserControl.Resources>
        <DataTemplate x:Key="ListItemTemplate">
            <Grid Margin="0,0,0,18">
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="80" />
                    <ColumnDefinition Width="*" />
                </Grid.ColumnDefinitions>
                <Image Grid.Column="0" HorizontalAlignment="Left" Source="{Binding Head, Converter={StaticResource HeadUrlConverter},ConverterParameter='50'}" Stretch="Fill" Width="60" Height="60" VerticalAlignment="Top"/>
                <StackPanel Grid.Column="1">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding NickName}" Style="{StaticResource TweetListAccount}"/>
                        <Image Source="/Resource/Icons/v.png" Stretch="Fill" Width="24" Height="24" Visibility="{Binding IsVip, Converter={StaticResource IntToVisibleConverter}}"/>
                    </StackPanel>
                    <StackPanel Orientation="Horizontal" HorizontalAlignment="Left">
                        <TextBlock Text="{Binding PublishTime,StringFormat='\{0\}说：'}" Style="{StaticResource TweetListMeta}" />
                        <TextBlock Text="{Binding Origtext,Converter={StaticResource MessageListTextConverter}}" Style="{StaticResource TweetListMeta}" Visibility="{Binding Origtext, Converter={StaticResource StringToVisibleConverter}}"/>
                    </StackPanel>
                </StackPanel>
            </Grid>
        </DataTemplate>
        <!--头部模板-->
        <DataTemplate x:Key="ListHeaderTemplate">
            <Grid Style="{StaticResource ListHeaderGrid}">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <Image Source="/Resource/Images/pull.png" Width="32" Height="32" VerticalAlignment="Center"/>
                    <TextBlock x:Name="tbHeaderText" Style="{StaticResource ListHeaderText}"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
        <!--底部模板-->
        <DataTemplate x:Key="ListFooterTemplate">
            <Grid Style="{StaticResource ListFooterGrid}">
                <StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
                    <TextBlock x:Name="tbFooterText" Style="{StaticResource ListFooterText}"/>
                </StackPanel>
            </Grid>
        </DataTemplate>
    </UserControl.Resources>
    <Grid x:Name="LayoutRoot" Background="Transparent" Style="{StaticResource ListLayoutGrid}">
        <toolkit:LongListSelector x:Name="DataListBox" 
                                  Background="Transparent" 
                                  toolkit:TiltEffect.IsTiltEnabled="True"
                                  IsFlatList="True"
                                  ItemTemplate="{StaticResource ListItemTemplate}"
                                  ListHeaderTemplate="{StaticResource ListHeaderTemplate}"
                                  ListFooterTemplate="{StaticResource ListFooterTemplate}"
                                  ShowListHeader="False"
                                  ShowListFooter="False"
                                  Tap="DataListBox_Tap"
                                  >
            <toolkit:GestureService.GestureListener>
                <toolkit:GestureListener  GestureCompleted="GestureListener_GestureCompleted"  GestureBegin="GestureListener_GestureBegin" />
            </toolkit:GestureService.GestureListener>
        </toolkit:LongListSelector>
    </Grid>
</UserControl>
